Input Devices


Objectives
Individual Assignment
1)Measure something: add a sensor to a micro-controller board that you have designed and read it.
Group Assignment
1)Probe an input device's analog levels and digital signals.

Step Response Sensor

I started out with an idea for a restive touch pad that a person could slide their finger across and it would change resistances just like a linear potentiometer. Essentially I wanted to make something like the SoftPot Potentiometer. but it was not a great range and quite noisy.I started by building the simple step response sensor described by Neil in class, to get a feel for using capacitance. I then decided to create a linear sensor with 8 capacitive nodes, borrowing some of the ideas and code from Matt Blackshaw's previous project. I decided to put my nodes in a chevron shape so that there would be some overlap between the nodes that were excited. Using this I could compute the touch location as the centroid and have a full analog slider instead of a discrete one.

Step Response Sensor,How it works?

A Step Response sensor, are input devices that act as a Heavyside Step Function; meaning, a change that goes from 0 to one in a very short period of time.
Capacitive Sensor:
The capacitance of a device is the ratio of the change in an electric charge in a system to the corresponding change in its electric potential 1.
Sometimes you put a dialectric material between the two plates of your capacitor . The capacitance of the system will vary in function of the conductivity of the material.
More details on this can be found in the following link.

Creating Slider And Board.

After testing the concept with Neils board, and being able to see that the sensor responds to the variation of the material that was set between the two cooper plates.So I started of using Eagle to create the Slider and  the circuit layout and milled it.

Mobirise

I routed it manually to get more ascetics.

Mobirise

Eagle schematic.

Mobirise

Stuffed the Micro controller(AtTiny84) and other Components.

Mobirise

Generated the Monochrome Trace And Milled.

Programming The Board.

With Help of Referring one of our instructors code(link.) and help from Jojin and Saheen I updated the Neil's code.
// Lots of learning.

//Updated Neil"s Code
// 9600 baud FTDI interface
//
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 9); // RX, TX


#include <avr/io.h >
#include <util/delay.h>

#define output(directions,pin) (directions |= pin) // set port direction for output
#define set(port,pin) (port |= pin) // set port pin
#define clear(port,pin) (port &= (~pin)) // clear port pin
#define pin_test(pins,pin) (pins & pin) // test for port pin
#define bit_test(byte,bit) (byte & (1 << bit)) // test for bit set
#define charge_delay_1() _delay_us(1) // charge delay 1
#define settle_delay() _delay_us(100) // settle delay
#define char_delay() _delay_ms(10) // char delay


#define charge_port PORTB
#define charge_direction DDRB
#define charge_pin (1 << PB2)

#define ref (0 << REFS1) | (0 << REFS0) // reference voltage

#define sense7 (0 << MUX2) | (0 << MUX1) | (0 << MUX0) // PA0
#define sense6 (0 << MUX2) | (0 << MUX1) | (1 << MUX0) // PA1
#define sense5 (0 << MUX2) | (1 << MUX1) | (0 << MUX0) // PA2
#define sense4 (0 << MUX2) | (1 << MUX1) | (1 << MUX0) // PA3
#define sense3 (1 << MUX2) | (0 << MUX1) | (0 << MUX0) // PA4
#define sense2 (1 << MUX2) | (0 << MUX1) | (1 << MUX0) // PA5
#define sense1 (1 << MUX2) | (1 << MUX1) | (0 << MUX0) // PA6
#define sense0 (1 << MUX2) | (1 << MUX1) | (1 << MUX0) // PA7

#define down_threshold 700
#define up_threshold 750


int check_pin(unsigned char pin) {
unsigned char up_lo,up_hi,down_lo,down_hi;
int up_value, down_value, value;

//
// set the A/D pin
//
ADMUX = ref | pin;

//
// settle, charge, and wait 1
//
settle_delay();
set(charge_port, charge_pin);
charge_delay_1();
//
// initiate conversion
//
ADCSRA |= (1 << ADSC);
//
// wait for completion
//
while (ADCSRA & (1 << ADSC))
;
//
// save result
//
up_lo = ADCL;
up_hi = ADCH;
//
// settle, discharge, and wait 1
//
settle_delay();
clear(charge_port, charge_pin);
charge_delay_1();
//
// initiate conversion
//
ADCSRA |= (1 << ADSC);
//
// wait for completion
//
while (ADCSRA & (1 << ADSC))
;
//
// save result
//
down_lo = ADCL;
down_hi = ADCH;
//
// process result
//
up_value = 256 * up_hi + up_lo;
down_value = 256 * down_hi + down_lo;
value = (up_value + (1023 - down_value)) / 2;

return value;
}

void sense_pin(unsigned char pin, int *oldValue, char labelChar) {
int value = check_pin(pin);

if ((*oldValue == 1 && value > up_threshold) || (*oldValue == 0 && value < down_threshold)) {
mySerial.print(labelChar);
char_delay();
if (*oldValue) {
*oldValue = 0;
mySerial.print('0');
}
else {
*oldValue = 1;
mySerial.print('1');
}
char_delay();
mySerial.print('\n');
char_delay();
}
}

int main(void) {

mySerial.begin(9600);

//
// main
//
static int touch1, touch2, touch3, touch4, touch5, touch6, touch7, touch8;
touch1 = touch2 = touch3 = touch4 = touch5 = touch6 = touch7 = touch8 = 0;

//
// set clock divider to /1
//
CLKPR = (1 << CLKPCE);
CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);
//
// initialize output pins

clear(charge_port, charge_pin);
output(charge_direction, charge_pin);
//
// init A/D
//
ADMUX = ref; // Vcc ref
ADCSRA = (1 << ADEN) // enable
| (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // prescaler /128
ADCSRB = (0 << ADLAR); // right adjust

//
// main loop
//
while (1) {
//
// sense pins
//
sense_pin(sense0, &touch1, '0');
sense_pin(sense1, &touch2, '1');
sense_pin(sense2, &touch3, '2');
sense_pin(sense3, &touch4, '3');
sense_pin(sense4, &touch5, '4');
sense_pin(sense5, &touch6, '5');
sense_pin(sense6, &touch7, '6');
sense_pin(sense7, &touch8, '7');
}
}

Test 101. Yesss its returning +1  with pre-defined value to a pad And I need to work out the program to calibrate.


Download Files here


RFID

RFID or Radio Frequency Identification system,A Reader consists of a Radio Frequency module and an antenna which generates high frequency electromagnetic field. On the other hand, the tag is usually a passive device, meaning it doesn’t contain a battery. Instead it contains a microchip that stores and processes information, and an antenna to receive and transmit a signal. A Reader generates an electromagnetic field which causes electrons to move through the tag’s antenna and subsequently power the chip.The powered chip inside the tag then responds by sending its stored information back to the reader in the form of another radio signal. This is called backscatter. The backscatter, or change in the electromagnetic/RF wave, is detected and interpreted by the reader which then sends the data out to microcontroller.
I used RC522 RFID Reader/Writer Module.

RC522 RFID Reader/Writer Module

The RC522 RFID Reader module is designed to create a 13.56MHz electromagnetic field that it uses to communicate with the RFID tags (ISO 14443A standard tags). The reader can communicate with a microcontroller over a 4-pin Serial Peripheral Interface (SPI) with a maximum data rate of 10Mbps. It also supports communication over I2C and UART protocols.

The module comes with an interrupt pin. It is handy because instead of constantly asking the RFID module “is there a card in view yet? “, the module will alert us when a tag comes into its vicinity.

The operating voltage of the module is from 2.5 to 3.3V
Frequency Range 13.56 MHz ISM Band
Host Interface SPI / I2C / UART
Operating Supply Voltage 2.5 V to 3.3 V
Max. Operating Current 13-26mA
Min. Current(Power down) 10µA
Logic Inputs 5V Tolerant
Read Range 5 cm

Mobirise





RFID PIN out.

Mobirise


How RFID Works?

Mobirise


Schematic

Mobirise


Board Routed.

Mobirise

Stuffed Board

Code

MFRC522 library which simplifies reading from and writing to RFID tags
https://github.com/miguelbalboa/rfid




#include <SPI.h >
#include <MFRC522.h>

#define SS_PIN 0
#define RST_PIN 1
#define KEY_RETURN 0xB0 //The hex value for the return key is 0xB0.

MFRC522 mfrc522 ( SS_PIN, RST_PIN ) ;
char Enter = KEY_RETURN; //Return key is declared as Enter.
String readid;
String card1 = "a6c15673"; //Change this value to the UID of your card.

void setup( )
{
Serial.begin(115200);
SPI.begin();
mfrc522.PCD_Init();
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
}

void temp(byte *buffer, byte bufferSize)//function to store card uid as a string datatype.
{
readid = "";
for (byte i = 0; i < bufferSize; i++)
{
readid = readid + String(buffer[i], HEX);
}
}
void loop( )
{
if (!mfrc522.PICC_IsNewCardPresent())
{
return;
}
if (!mfrc522.PICC_ReadCardSerial())
{
return;
}
// mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); // Display card details in serial Monitor.
temp(mfrc522.uid.uidByte, mfrc522.uid.size);
if (readid == card1)
{
Serial.println("haii abel");
digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(6, LOW); // turn the LED off by making the voltage LOW
delay(2000); // wait for a

}
else
{ Serial.println("who the f*ck are you");
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(2000);

}
}


Mobirise

Person Identified.  ;)


Download design Files.Click here.


Copyright © 2021 Abel's FAB Student agreement .All rights reserved

Created with Mobirise - Check it